<?php

namespace Medicina\KernelBundle\Entity;

use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\Validator\Constraints as Assert;
use Symfony\Bridge\Doctrine\Validator\Constraints as DoctrineAssert;


/**
 * Medicina\KernelBundle\Entity\Persona
 *
 * @ORM\Table(name="persona")
 * @ORM\Entity
 * @ORM\Entity(repositoryClass="Medicina\KernelBundle\Entity\PersonaRepository")
 */
class Persona {

    /**
     * @ORM\Column(name="id", type="integer", nullable=false)
     * @ORM\Id
     * @ORM\GeneratedValue(strategy="IDENTITY")
     */
    private $id;

    /**
     * @ORM\Column(name="email", type="string", length=50, nullable=false)  
     */
    private $email;

    /**
     * @ORM\Column(name="telefono", type="string", length=20, nullable=false)
     */
    private $telefono;

    /**
     * @ORM\Column(name="nombre", type="string", length=50, nullable=false)
     */
    private $nombre;

    /**
     * @ORM\Column(name="apellido", type="string", length=50, nullable=false)
     */
    private $apellido;

    /**
     * @ORM\Column(name="dni", type="string", length=8, nullable=false, unique=true)
     */
    private $dni;

    /**
     * @ORM\Column(name="direccion", type="string", length=30, nullable=false)
     */
    private $direccion;

    /**
     * @ORM\Column(name="codigoPostal", type="string", length=8, nullable=false)
     */
    private $codigopostal;

    /**
     * @ORM\OneToMany(targetEntity="PersonaOcupaCargo", mappedBy="cargo", cascade={"persist"})
     */
    private $cargos;

    /**
     * @ORM\OneToMany(targetEntity="PersonaAsesora", mappedBy="persona", cascade={"persist"})
     */
    private $asesoraConcursos;

    /**
     * @ORM\OneToMany(targetEntity="PersonaInscripta", mappedBy="persona", cascade={"persist"})
     */
    private $inscriptaConcursos;

    public function __construct() {
        $this->cargos = new \Doctrine\Common\Collections\ArrayCollection();
        $this->asesoraConcursos = new \Doctrine\Common\Collections\ArrayCollection();
        $this->inscriptaConcursos = new \Doctrine\Common\Collections\ArrayCollection();
    }

    public function getId() {
        return $this->id;
    }

    public function setEmail($email) {
        $this->email = $email;
    }

    public function getEmail() {
        return $this->email;
    }

    public function setTelefono($telefono) {
        $this->telefono = $telefono;
    }

    public function getTelefono() {
        return $this->telefono;
    }

    public function setNombre($nombre) {
        $this->nombre = $nombre;
    }

    public function getNombre() {
        return $this->nombre;
    }

    public function setApellido($apellido) {
        $this->apellido = $apellido;
    }

    public function getApellido() {
        return $this->apellido;
    }

    public function setDni($dni) {
        $this->dni = $dni;
    }

    public function getDni() {
        return $this->dni;
    }

    public function setDireccion($direccion) {
        $this->direccion = $direccion;
    }

    public function getDireccion() {
        return $this->direccion;
    }

    public function setCodigopostal($codigopostal) {
        $this->codigopostal = $codigopostal;
    }

    public function getCodigopostal() {
        return $this->codigopostal;
    }

    public function addCargo(\Medicina\KernelBundle\Entity\PersonaOcupaCargo $cargos) {
        $this->cargos[] = $cargos;
    }

    public function getCargos() {
        return $this->cargos;
    }

    public function addPersonaAsesora(\Medicina\KernelBundle\Entity\PersonaAsesora $asesoraConcursos) {
        $this->asesoraConcursos[] = $asesoraConcursos;
    }

    public function getAsesoraConcursos() {
        return $this->asesoraConcursos;
    }

    public function addPersonaInscripta(\Medicina\KernelBundle\Entity\PersonaInscripta $inscriptaConcursos) {
        $this->inscriptaConcursos[] = $inscriptaConcursos;
    }

    public function getInscriptaConcursos() {
        return $this->inscriptaConcursos;
    }

    public function __toString() {
        return $this->getApellido() . ', ' . $this->getNombre();
    }

    /**
     * Add cargos
     *
     * @param Medicina\KernelBundle\Entity\PersonaOcupaCargo $cargos
     */
    public function addPersonaOcupaCargo(\Medicina\KernelBundle\Entity\PersonaOcupaCargo $cargos) {
        $this->cargos[] = $cargos;
    }

    public function getInfoShow() {
        return $this->getApellido() . $this->getNombre() . " | " . $this->getDireccion() . " | " . $this->getTelefono() . " | " . $this->getCodigopostal() . " | " . $this->getEmail();
    }

    public function getJsonForAjaxEdit() {
          return $output = array(
            'email' => $this->getEmail(),
            'nombre' => $this->getNombre(),
            'apellido' => $this->getApellido(),
            'dni' => $this->getDni(),
            'direccion' => $this->getDireccion(),
            'codigopostal' => $this->getCodigopostal(),
            'telefono' => $this->getTelefono(),
        );
    }
}